/**
 * @author 雷明浩
 * @date 2025/5/29 16:05
 */
public class MaxDepth {
    // leetcode 二叉树的最大深度
    // https://leetcode.cn/problems/maximum-depth-of-binary-tree/?envType=study-plan-v2&envId=top-100-liked
    public int maxDepth(TreeNode root) {
        if (root == null) {
            return 0;
        }
        int leftTreeMaxDeepth = maxDepth(root.left);
        int rightTreeMaxDeepth = maxDepth(root.right);
        return Math.max(leftTreeMaxDeepth, rightTreeMaxDeepth) + 1;
    }
}